//
//  BirthdayCell.m
//  FD
//
//  Created by Yasin on 2018/10/17.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "BirthdayCell.h"
@interface BirthdayCell()
/**编辑按钮*/
@property (nonatomic,  strong) UIButton *editBtn;

@end

@implementation BirthdayCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
        
        //取消点击样式
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        //关闭按钮的点击时间
        self.editBtn.userInteractionEnabled = NO;
    }
    return self;
}

- (void)setupView
{
    [self.contentView addSubview:self.nameLb];
    [self.contentView addSubview:self.birthdayLb];
    [self.contentView addSubview:self.editBtn];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(100, 25));
    }];
    [self.birthdayLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(120, 25));
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.right.equalTo(self.editBtn.mas_left);
    }];
    [self.editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(30, 30));
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
    }];
}
- (UILabel *)nameLb {
    if (!_nameLb) {
        _nameLb = [UILabel new];
    }
    return _nameLb;
}
- (UILabel *)birthdayLb {
    if (!_birthdayLb) {
        _birthdayLb = [UILabel new];
        _birthdayLb.textColor = [UIColor lightGrayColor];
        _birthdayLb.textAlignment = NSTextAlignmentRight;
    }
    return _birthdayLb;
}
- (UIButton *)editBtn {
    if (!_editBtn) {
        _editBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_editBtn setImage:[UIImage imageNamed:@"edit"] forState:(UIControlStateNormal)];
    }
    return _editBtn;
}

@end
